# -*- coding: utf-8 -*-

from tornado.options import define, options
import re

def parse_config_file(path):
	config = {}
	execfile(path, config, config)
	
	for name in config:
		if name in options:
			options[name].set = config[name]
		else:
			define(name, config[name])

'''
正则匹配淘宝url，获取商品Id
'''
def get_taobao_id(url):
	if not url:
		return None
	match = re.match(r'http:\/\/item.taobao.com\/item.htm\?id\=(\d+)(.*)',url)
	if match:
		id = match.group(1)
		if id<1000000:
			return None
		return id
	else:
		return None
	
